import { Injectable } from '@angular/core';
import { State } from '@ngxs/store';
import { PagedResultDto } from '@abp/ng.core';
import {
  defaultEntityListState,
  EntityListStateModel,
  EntityListStore,
} from '../../core/entity-list.state.base';
import { TenantDto, TenantService } from '../proxy';

@State<EntityListStateModel<TenantDto>>({
  name: 'TenantList',
  defaults: defaultEntityListState(),
})
@Injectable()
export class TenantListState extends EntityListStore<TenantDto> {
  constructor(protected tenantService: TenantService) {
    super(TenantListState);
  }
  protected onGetModels(payload: any): Promise<PagedResultDto<TenantDto>> {
    return this.tenantService.getList(payload).toPromise();
  }
  protected onDelete(payload: string): Promise<void> {
    return this.tenantService.delete(payload).toPromise();
  }
}
